<?php

#################################################################
#								HTML
#################################################################

/**
 * Register form registed as 'layout/form/radio_list'
 * $vars['options'][] = array('label', 'value');
 * $vars['checked']	(INT array index) 
 * $vars['name']
 * $vars['class']
 * $vars['radio_class']
 * $vars['onClick']
 * $vars['display']
 */

if($_CONTEXT=='HTML' && count($vars['options'])>0){
	$_CSS_STACK->push(blg_get_site_url().'layout/form/radio_list.css', TRUE);
	$_JS_STACK->push(blg_get_site_url().'layout/form/radio_list.js', TRUE);	
	
	$div_class= 'blg_radio_list'.(!empty($vars['class'])?' '.$vars['class']:'');
	
	if(!in_array($vars['display'], array('row', 'col')))
		$vars['display']= 'col';
	
	$content= '<div class="'.$div_class.'">';	
	foreach($vars['options'] as $i => $row){
		list($label, $value)= $row;
		$content.= '<div class="blg_radio_list_layout_'.$vars['display'].'">';
		$content.= blg_view('element/radio', array(
			'name' 	=> $vars['name'],
			'value'	=> $value,
			'label' => $label,
			'checked' => ($i===$vars['checked']),
			'class' => $vars['radio_class'],
			'onClick' => $vars['onClick']			
		));	
		$content.= '</div>';	
	}	
	$content.= '</div>';

	echo $content;
}
#################################################################
#								JS
#################################################################
elseif($_CONTEXT=='JS'){ ?>

<?php }
#################################################################
#								CSS
#################################################################
elseif($_CONTEXT=='CSS'){ ?>

div.blg_radio_list_layout_col{
	display: block;
}

div.blg_radio_list_layout_row{
	display: inline;
	margin: 0 8px 0 0;
}

<?php }
		